﻿
//全局URL变量
var fg_URL = "http://fugaomobile.ngrok.com/weixin/";



function SetString(str, len) {

    var strlen = 0; var s = ""; if (str != null) {
        for (var i = 0; i < str.length; i++) {
            if (str.charCodeAt(i) > 128) {
                strlen += 2;
            }
            else {
                strlen++;
            }
            s += str.charAt(i);
            if (strlen > len) {
                return s + "...";
            }
        }
    } return s;
}
function ChangeDateFormat(val) {
    if (val != null) {
        var date = new Date(parseInt(val.replace("/Date(", "").replace(")/", ""), 10));
        //月份为0-11，所以+1，月份小于10时补个0  
        var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
        var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
        return date.getFullYear() + "-" + month + "-" + currentDate;
    }
    return "";
}



function HtmlEncode(theString) {
    if(theString!=null){
    if (theString.length > 0) {
        theString = theString.replace(">", ">");
        theString = theString.replace("<", "<");
        theString = theString.replace(" ", "  ");
        theString = theString.replace("\"", "'");
        theString = theString.replace("\'", "'");
        theString = theString.replace("\n", "<br/>");
    }
    }
    return theString;
}
function HtmlUncode(theString) {
    if (theString != null) {
        if (theString.length > 0) {
            theString = theString.replace(">", ">");
            theString = theString.replace("<", "<");
            theString = theString.replace("  ", " ");
            theString = theString.replace("'", "\'");
            theString = theString.replace("'", "\"");
            theString = theString.replace("<br/>", "\n");
            theString = theString.replace("<br/>", "\r\n");
        }
    }
    return theString;
}